﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace ETC.DLEDLightingSystemPlus.Helpers
{
    public class TitleNameConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string str = null;

            if (value is string)
            {
                str = value.ToString();
            }

            string result = string.Format("{0}-AUTO V{1}  - [IP : {2}]{3}", this.GetAssemblyName(), this.GetVersion(), Bandit.SystemFunction.IPAddress, string.IsNullOrWhiteSpace(str) ? "" : " for " + str);

            return result;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string result = string.Format("{0} V{1} - [IP : {2}]", this.GetAssemblyName(), this.GetVersion(), Bandit.SystemFunction.IPAddress);

            return result;
        }
    }

    public class ImageNameConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string str = null;

            if (value is string)
            {
                str = value.ToString();
            }

            string result = this.GetBaseDirectory() + "DIYImages\\" + Path.GetFileName(str);

            if (!File.Exists(result))
            {
                result = this.GetBaseDirectory() + "1.png";
            }

            return result;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
